Skip to content

Use target sysconfig for platform-qualified stable-ABI suffixes - #5352

Merged
jaraco merged 1 commit into
pypa:mainfrom
jameshilliard:fix/abi3-target-platform
Oct 19, 2026
Merged

jaraco merged 1 commit into
pypa:mainfrom
jameshilliard:fix/abi3-target-platform

Conversation

@jameshilliard

@jameshilliard jameshilliard commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary of changes

Python 3.15 includes platform-qualified stable-ABI suffixes in EXTENSION_SUFFIXES. During cross-compilation, these describe the running interpreter rather than the target, which can leave extensions with filenames the target cannot import.

Construct stable-ABI suffixes from target sysconfig data instead of the running interpreter's EXTENSION_SUFFIXES. Preserve the file extension from EXT_SUFFIX, select ABI3 or ABI3T using Py_GIL_DISABLED, and add the platform qualifier from SOABI_PLATFORM when available. Keep the helper's no-argument API and fall back to an unqualified suffix when the target platform is unavailable.

Add regression tests covering target suffixes, version-independent ABI3T selection, preservation of the file extension, the fallback, Windows, Cygwin, HP-UX, and consistent filenames across build_ext and wheel builds, including --skip-build.

Closes #5351

Testing

  • Python 3.15: 75 tests passed across test_build_ext.py and test_bdist_wheel.py.
  • Python 3.14: 79 checks passed across test_build_ext.py, test_bdist_wheel.py, and mypy.
  • Native extension build/import smoke tests passed on Python 3.14 and 3.15, with unchanged filenames.
  • Cross-build smoke test using a Python 3.15 host and Buildroot's AArch64 toolchain and Python 3.14 target configuration: the original code produced an extension with an x86-64 suffix that failed to import on the target; the patched code produced an extension that imported successfully under QEMU.
  • Ruff lint and formatting checks, and git diff --check, passed.

Pull Request Checklist

@vfazio

vfazio commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Eli just lmk about PEP 739.

https://peps.python.org/pep-0739/

python/cpython#122931 (comment)

@ngoldbaum

Copy link
Copy Markdown
Contributor

See #5193 which touches the same code and also bears on Python 3.15 support. I'm happy to help with issues here and I've been struggling to get the attention of a setuptools maintainer about Python 3.15 support.

@jaraco

jaraco commented Oct 19, 2026

Copy link
Copy Markdown
Member

Thanks @jameshilliard, and @vfazio for the report. I've written up how this relates to #5193 in #5193 (comment).

Short version: this lands first. It fixes a regression against released 3.15, it touches only build_ext.py where #5193 touches only bdist_wheel.py, and it is behavior-preserving for native builds — I compared the current and proposed implementations directly:

python 3.14.8   current='.abi3.so'          this PR='.abi3.so'          same
python 3.15.0   current='.abi3-darwin.so'   this PR='.abi3-darwin.so'   same

It diverges only when sysconfig describes a target other than the running interpreter, which is the case being fixed.

On scope: I agree with drawing the line where you've drawn it. The residual host-vs-target leaks you identified in your review of #5193 — _validate_py_limited_api comparing sys.version_info, and get_tag() relying on tags.sys_tags() / interpreter_name() / interpreter_version() — belong in their own change, and I'll file an issue for them rather than growing this PR.

The CI failures showing on the 3.10 through 3.14 jobs here were from a RUF100 failure on main under Ruff 0.17, unrelated to this PR; that's fixed in main now (#5356), so a rebase or merge of main should give you a readable run.

Python 3.15 includes platform-qualified stable-ABI suffixes in
EXTENSION_SUFFIXES. During cross-compilation, these describe the
running interpreter rather than the target, which can leave extensions
with filenames the target cannot import.

Construct stable-ABI suffixes from target sysconfig data instead.
Preserve the file extension from EXT_SUFFIX, select ABI3 or ABI3T using
Py_GIL_DISABLED, and add SOABI_PLATFORM when available. Keep the
no-argument helper API and use an unqualified suffix when the target
platform is unavailable.

Preserve Windows debug and unsupported-loader behavior, including
Cygwin and HP-UX. Cover target suffixes, version-independent ABI3T
selection, the fallback, and consistent filenames across build_ext and
wheel builds, including --skip-build.

Closes pypa#5351
@jameshilliard
jameshilliard force-pushed the fix/abi3-target-platform branch from 28b1988 to 97b75e6 Compare October 19, 2026 19:23
@jaraco
jaraco merged commit b3985b6 into pypa:main Oct 19, 2026
25 of 26 checks passed
@jameshilliard
jameshilliard deleted the fix/abi3-target-platform branch October 19, 2026 19:58
jaraco added a commit to ngoldbaum/setuptools that referenced this pull request Oct 19, 2026
Reconciles with pypa#5352, which landed the target-sysconfig rewrite of
get_abi3_suffix() in build_ext.py. The two changes are complementary --
pypa#5352 fixes the extension filename, this branch fixes the wheel tag --
so the only collisions are in tests.

test_bdist_wheel.py: keep both imports; stable_abi_tag from here and
get_abi3_suffix from pypa#5352.

test_build_ext.py: git merges this file cleanly but leaves it broken.
test_stable_abi_filename patched build_ext.EXTENSION_SUFFIXES, and pypa#5352
removed that import, so monkeypatch.setattr raised AttributeError on both
parametrizations. Rather than drop the test (which would orphan the
check_stable_abi helper and lose native coverage), drive it from the
configured target: it now asserts abi3t on a free-threaded build and abi3
otherwise, which exercises the real code path instead of a simulated
suffix list. pypa#5352's test_abi3_filename_cross already covers cross-build
naming for both ABIs, so the simulated suffix fixtures are redundant.

Ref pypa#5193 (comment)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] cross compiling 3.15 abi3 wheels fails due to new multiarch support

4 participants